var e = getApp(), a = e.requirejs("core"), t = e.requirejs("wxParse/wxParse"), i = e.requirejs("biz/diypage"), s = e.requirejs("jquery");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 轮播图数组
    swiperList: [],
    plateList: [],
    recommendList: [],
    show: true
  },
  //  全局cid
  cid: '',
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 授权
    var t = this;
    e.url(a), wx.getSystemInfo({
      success: function (e) {
        var a = e.windowWidth / 1.7;
        t.setData({
          windowWidth: e.windowWidth,
          windowHeight: e.windowHeight,
          swiperheight: a
        });
      }
    }), i.get(this, "forum", function (e) { }), "" == e.getCache("userinfo") && wx.redirectTo({
      url: "/pages/message/auth/index"
    });

    this.init()
  },
  // 获取轮播图数据
  init() {
    let me = this;
    a.get('sns/get_index', {}, function (res) {
      // console.log(res)
      let swiperList = res.result.adv
      let plateList = res.result.category
      let recommendList = res.result.recommands
      // console.log(res)
      me.setData({
        swiperList,
        plateList,
        recommendList
      });
    });
  },

  // 首页获取cid
  handlecid(e) {
    // console.log(e);
    this.cid = e.currentTarget.dataset.id
    // console.log( this.cid);
    wx.setStorageSync('cid', this.cid)
  },

  onShow: function () {
    var e = this;
    wx.getSetting({
      success: function (a) {
        var t = a.authSetting["scope.userInfo"];
        e.setData({
          limits: t
        }), t || wx.redirectTo({
          url: "/pages/message/auth/index"
        });
      }
    });
  },
})